<template>
  <div class="page-view">
    <!-- <ContainerHeader title="筛选条件" /> -->
    <div class="main-box  wd1200" style="padding-bottom:100px">
      <!-- <div class="sidebar">
        <FilterSidebar v-model="activeItemIndex" :option="treeList" />
      </div> -->
      <div class="content" id="listContent">
        <div
          :id="item._id"
          class="filter-box"
          v-for="(item, index) in treeList"
          :key="index"
          :class="{ 'is-hidden': item.hidden }"
        >
          <div class="filter-title">{{ item.name }}</div>
          <!-- <div class="filter-tags" :class="{ 'is-column': item.isColumn }"> -->
          <template v-if="item.type == 'input'">
            <div class="search-block">
              <el-input v-model="searchWord" placeholder="输入关键词，可指定搜索范围，至少2个字">
              	<el-button slot="append" icon="el-icon-search" @click="searchByWord"></el-button>
              </el-input>
            </div>
          </template>
          <template v-if="item.type == 'customPicker'">
            <div class="filter-tags is-column">
              <p
                class="filter-tag"
                v-for="(tag, tindex) in item.children"
                :key="tindex"
                :class="{
                  'is-selected': customPickerName,
                }"
                @click="categoryVisibleNew = true"
              >
                <span>{{ customPickerName || tag.name }}</span>
              </p>
            </div>
          </template>
          <template v-else>
            <div class="filter-tags" :class="{ 'is-column': item.deepNum > 2 }">
              <p
                class="filter-tag"
                v-for="(tag, tindex) in item.children"
                :key="tindex"
                :class="{
                  'is-selected':
                    tag.selected ||
                    (item.deepNum >= 2 && pickerList[tag._id]) ||
                    (item.type == 'customParam' &&
                      customParam[item.param] &&
                      customParam[item.param].indexOf(tindex) != -1),
                }"
                @click="onTagClick(tag, item, index, tindex)"
              >
                <!-- <span v-if="item.deepNum >= 2 && pickerList[tag._id]">{{
                  pickerList[tag._id].name
                }}</span> -->
				<span v-if="item.deepNum > 2">{{ tag.name }}</span>
                <span v-else>{{ tag.name }}</span>
              </p>
            </div></template
          >
        </div>
      </div>
    </div>
    <div class="filter-footer resultcontainer">
      <!-- <button class="footer-button" @click="resetFilter">重置</button>
      <button
        class="footer-button is-primary"
        @click="goPageGlobal('/home-enterprise')"
      >
        <van-loading v-if="enterpriseListLoading" /> 查看
        {{ enterpriseTotal }} 家企业
      </button> -->
	  <div class="wd1200">
	  	为你找到 <span class="number">{{enterpriseTotal}}</span> 家符合条件的企业
	  	<div class="fr">
	  		<!-- <el-button>重置</el-button> -->
	  		<el-button type="primary" @click="seeresult">查看结果</el-button>
	  	</div>
	  </div>
    </div>
    <van-popup v-model="showPicker" round position="bottom">
      <van-picker
        show-toolbar
        title=""
        :columns="pickerColumns"
        value-key="name"
        @confirm="confirmPicker"
        @cancel="showPicker = false"
      />
    </van-popup>
    <CategoryPopup
      :visible.sync="categoryVisible"
      @confirmCategpry="confirmCategpry"
    ></CategoryPopup>
    <CategoryPopupNew
      :visible.sync="categoryVisibleNew"
      @confirmCategpry="confirmCategpry"
    ></CategoryPopupNew>
  </div>
</template>

<script>
import { mapMutations, mapGetters, mapActions, mapState } from "vuex";
import {
		sdqygjssv1api,
		industryapi,
		industryapi2,
		industryapi3,
		qylxdictapi
	} from "@/api/enterprise/index";
// import FilterSidebar from "./components/filterSidebar.vue";
// import CategoryPopup from "./components/categoryPopup.vue";
// import CategoryPopupNew from "./components/categoryPopupNew.vue";
import filterOption from "./scripts/filterOption";
export default {
	
  // components: {
  //   FilterSidebar,
  //   CategoryPopup,
  //   CategoryPopupNew,
  // },
  data() {
    return {
      categoryVisibleNew: false,
      categoryVisible: false,
      filterOption,
      activeItemIndex: 0,
      treeList: [],
      showPicker: false,
      pickerColumns: [],
      pickerList: {},
      currentPicker: {},
      keyWordSearch: [],
      searchWord: "",
      fwList: [
        {
          name: "企业名",
          _id: "ent_name",
        },
        {
          name: "法人/股东",
          _id: "name",
        },
        {
          name: "地址",
          _id: "dzmc",
        },
        {
          name: "经营范围",
          _id: "opscope",
        },
        {
          name: "招聘",
          _id: "zpmc",
        },
        {
          name: "商标",
          _id: "sbmc",
        },
        {
          name: "专利",
          _id: "zlmc",
        },
        {
          name: "网站",
          _id: "wzmc",
        },
      ],
      customPickerName: "",
      categoryArr: [],
      customParam: {},
	  total:0
    };
  },
  computed: {
    ...mapState("home", ["savePickerList", "enterpriseListLoading"]),
    ...mapGetters("home", ["enterpriseParams", "enterpriseTotal"]),
    __column() {
      // 首先调用initTree方法查找所有parent_id为-1的（-1认为是第一级）
      return this.filterOption.column || [];
    },
  },
  watch: {
    enterpriseParams: {
      handler(v) {
        let key = [
          "industry_one",
          "industry_two",
          "industry_three",
          "industry_four",
        ];
        key.forEach((j, i) => {
          if (v[j]) {
            this.customPickerName = v[j];
            this.categoryArr.push(v[j]);
          }
        });
        let customParam = ["cbrs", "clnx", "zczb", "sjzb"];
        customParam.forEach((j, i) => {
          if (v[j]) {
            this.customParam[j] = v[j].split(",").map((v) => +v - 1);
          } else {
            this.$delete(this.customParam, j);
          }
        });
      },
      deep: true,
      immediate: true,
    },
    pickerList: {
      handler(v) {
        let currentParam = { ...this.enterpriseParams };
        if (Object.keys(v).length == 0) {
          this.setEnterpriseParams({
            ...this.enterpriseParams,
            pageNumber: 1,
            tagId: [],
          });
          this.getEnterPriseList();
        } else {
          let tagId = [];
          let chooseKey = {};
          for (let key in v) {
            let hasIndex = this.keyWordSearch.findIndex((j) => j == v[key]._id);
            if (v[key] && hasIndex == -1) {
              (
                chooseKey[v[key].parentId] || (chooseKey[v[key].parentId] = [])
              ).push(v[key]._id);
            }
          }
          for (let key in chooseKey) {
            tagId.push(chooseKey[key].join(","));
          }
          let keyWordParams = {};
          if (this.keyWordSearch.length && this.searchWord) {
            let hasId = this.fwList.map((v) => v._id);
            hasId.forEach((v) => {
              currentParam[v] = "";
            });
            this.keyWordSearch.forEach((v) => {
              keyWordParams[v] = this.searchWord;
            });
          }
          this.setEnterpriseParams({
            ...currentParam,
            ...keyWordParams,
            tagId,
            pageNumber: 1,
          });
          this.getEnterPriseList();
        }
        this.setEnterprisePickerList(v);
      },
      deep: true,
      // immediate: true,
    },
  },
  methods: {
	  seeresult(){},
    ...mapActions("home", ["getEnterPriseList"]),
    ...mapMutations("home", [
      "setEnterpriseParams",
      "setEnterpriseList",
      "setEnterprisePickerList",
    ]),
    selectFormatList() {
      let chooseKey = {};
      let ll = this.pickerList;
      for (let key in ll) {
        let hasIndex = this.keyWordSearch.findIndex((j) => j == ll[key]._id);
        if (ll[key] && hasIndex == -1) {
          (
            chooseKey[ll[key].parentId] || (chooseKey[ll[key].parentId] = [])
          ).push(ll[key]._id);
        }
      }
      this.treeList = this.treeList.map((v) => {
        if (v.type == "customParam") {
          v.children &&
            v.children.forEach((k, i) => {
              if (
                this.customParam[v.param] &&
                this.customParam[v.param].indexOf(i) != -1
              ) {
                (v.value || (v.value = [])).push(k._id);
                k.selected = true;
              }
            });
        } else {
          if (chooseKey[v._id]) {
            v.children &&
              v.children.forEach((j) => {
                if (chooseKey[v._id].indexOf(j._id) != -1) {
                  (v.value || (v.value = [])).push(j._id);
                  j.selected = true;
                }
              });
          }
        }
        return {
          ...v,
        };
      });
    },
    setCustomParam(item) {
      let param = [];
      item.children.forEach((v, i) => {
        if (v.selected) {
          param.push(i + 1);
        }
      });
      this.setEnterpriseParams({
        ...this.enterpriseParams,
        [item.param]: param.join(","),
        pageNumber: 1,
      });
      this.getEnterPriseList();
    },
    confirmCategpry(e, arr) {
      this.customPickerName = "";
      for (let i = arr.length - 1; i >= 0; i--) {
        if (arr[i].code) {
          this.customPickerName = arr[i].industryName;
          break;
        }
      }
      this.categoryVisibleNew = false;
      this.categoryVisible = false;
      this.setEnterpriseParams({ ...this.enterpriseParams, ...e });
      this.getEnterPriseList();
    },
    searchByWord(search = true) {
      let keyWordParams = {};
      let hasId = this.fwList.map((v) => v._id);
      let currentParam = { ...this.enterpriseParams };
      hasId.forEach((v) => {
        currentParam[v] = "";
      });
      if (this.keyWordSearch.length && this.searchWord) {
        this.keyWordSearch.forEach((v) => {
          keyWordParams[v] = this.searchWord;
        });
      } else {
        keyWordParams["ent_name"] = this.searchWord;
      }
      this.setEnterpriseParams({
        ...currentParam,
        ...keyWordParams,
        pageNumber: 1,
      });
      if (search) {
        this.getEnterPriseList();
      }
    },
    resetFilter() {
      this.setEnterpriseParams({ pageNumber: 1, pageSize: 20 });
      this.treeList = this.treeList.map((v) => {
        let children =
          v.children &&
          v.children.map((j) => {
            return {
              ...j,
              selected: false,
            };
          });
        return {
          ...v,
          children,
          value: [],
        };
      });
      this.customPickerName = "";
      this.searchWord = "";
      this.keyWordSearch = [];
      this.pickerList = {};
      this.$forceUpdate();
    },
    confirmPicker(e, chooseIndex) {
      // 判断是否是多级联选
      if (chooseIndex instanceof Array) {
        let current = this.currentPicker;
        chooseIndex.forEach((v) => {
          let child = current.children[v];
          //如果不存在子集 取父级
          if (child.child != -1 && child.name != "不限") {
            current = child;
          }
        });
        let wxList = e.filter((v) => v == "不限");
        // this.pickerList[this.currentPicker._id] = current;
        if (wxList.length == e.length) {
          this.$delete(this.pickerList, this.currentPicker._id);
        } else {
          this.$set(this.pickerList, this.currentPicker._id, current);
        }
      } else {
        // this.pickerList[this.currentPicker._id] =
        //   this.currentPicker.children[chooseIndex];
        if (e.child == -1) {
          this.showPicker = false;
          return;
        }
        if (e._id) {
          this.$set(
            this.pickerList,
            this.currentPicker._id,
            this.currentPicker.children[chooseIndex]
          );
        } else {
          this.$delete(this.pickerList, this.currentPicker._id);
        }
      }
      this.showPicker = false;
    },
    toTree(data) {
      // 删除 所有 children,以防止多次调用
      data.forEach(function (item) {
        delete item.children;
      });

      // 将数据存储为 以 id 为 KEY 的 map 索引数据列
      var map = {};
      data.forEach(function (item) {
        map[item._id] = item;
      });
      var val = [];
      data.forEach(function (item) {
        // 以当前遍历项，的pid,去map对象中找到索引的id
        var parent = map[item.parentId];
        // 好绕啊，如果找到索引，那么说明此项不在顶级当中,那么需要把此项添加到，他对应的父级中
        if (parent) {
          (parent.children || (parent.children = [])).push(item);
        } else {
          //如果没有在map中找到对应的索引ID,那么直接把 当前的item添加到 val结果集中，作为顶级
          val.push(item);
        }
      });
      return val;
    },
    getDepth(obj) {
      if (obj.children === undefined || obj.children.length === 0) {
        return 1;
      }
      let maxDepth = 0;
      for (let i = 0; i < obj.children.length; i++) {
        const childDepth = this.getDepth(obj.children[i]);
        maxDepth = Math.max(maxDepth, childDepth);
      }
      return maxDepth + 1;
    },
    //tag 当前点击这层 item 最外面那层
    onTagClick(tag, item, index, tindex) {
		console.log('tag',tag)
		console.log('item',item)
		console.log('index',index)
		console.log('tindex',tindex)
      if (item.deepNum > 2) {
        if (item.deepNum > 3) {
          if (!tag.children) {
            tag.children = [
              {
                child: -1,
                name: " ",
                id: tag._id,
              },
            ];
          }
          tag.children.forEach((v) => {
            // 没有子集的情况
            if (!v.children && this.getDepth(tag) > 2) {
              v.children = [
                {
                  child: -1,
                  name: " ",
                  id: v._id,
                },
              ];
            }
          });
        }
        this.pickerColumns = [...tag.children];
        this.currentPicker = { ...tag };
        this.$forceUpdate();
        this.showPicker = true;
        return;
      }
      this.$set(tag, "selected", !tag.selected);
      if (tag.selected) {
        // 选中tag
        (item.value || (item.value = [])).push(tag._id);
        if (item.type == "customParam") {
          this.setCustomParam(item);
          return;
        }
        this.$set(this.pickerList, tag._id, tag);
        if (item.type == "customSearch") {
          this.keyWordSearch.push(tag._id);
        }
      } else {
        if (item.type == "customSearch") {
          this.keyWordSearch = this.keyWordSearch.filter((v) => v != tag._id);
          this.searchByWord(false);
        }
        // 取消选中 tag
        item.value = item.value.filter((tagValue) => tagValue !== tag._id);
        this.pickerList[tag._id] = null;
        delete this.pickerList[tag._id];
        // this.$set(this.pickerList, tag._id, null);
        if (item.type == "customParam") {
          this.setCustomParam(item);
        }
      }
    },
    pushCostomData(v, obj, tempTreeList) {
      let fxIndex = tempTreeList.findIndex((j) => j.name == obj.name);
      if (fxIndex == -1) {
        tempTreeList.push({
          name: obj.name,
          _id: obj.id,
          children: [],
        });
      } else {
        if (Object.keys(obj.list).indexOf(v.name) != -1) {
          tempTreeList[fxIndex].children.push(v);
        }
      }
    },
    deep(list, key) {
      for (let i = 0; i < list.length; i++) {
        const element = list[i];
        element._id = key + "_" + element._id;
        if (element.children && element.children.length > 0) {
          this.deep(element.children, key);
        }
      }
    },
    // 每个查询条件对应的前缀：
    // company_base_tag_search_gsxx_cbrs	高级搜索-工商信息-参保人数
    // company_base_tag_search_gsxx_clnx	高级搜索-工商信息-成立年限
    // company_base_tag_search_gsxx_zczb	高级搜索-工商信息-注册资金
    // company_base_tag_search_gsxx_sjzb	高级搜索-工商信息-实缴资本

    // company_base_tag_search_gsxx_qyzd	高级搜索-工商信息-企业状态
    // company_base_tag_search_gsxx_zblx	高级搜索-工商信息-资本类型
    // company_base_tag_search_gsxx_qylx	高级搜索-工商信息-企业类型
    // company_base_tag_search_gsxx_zjjg	高级搜索-工商信息-组织机构
    // company_base_tag_search_lxfs_ysdjz	高级搜索-联系方式-疑似代记账
    // company_base_tag_search_lxfs_lxdh	高级搜索-联系方式-联系电话
    // company_base_tag_search_lxfs_sjhm	高级搜索-联系方式-手机号码
    // company_base_tag_search_lxfs_gddh	高级搜索-联系方式-固定电话
    // company_base_tag_search_lxfs_gwdh	高级搜索-联系方式-官网电话
    // company_base_tag_search_lxfs_gzldh	高级搜索-联系方式-高质量电话
    // company_base_tag_search_lxfs_lxyx	高级搜索-联系方式-联系邮箱
    // company_base_tag_search_fxxx_sxbzxr	高级搜索-风险信息-失信被执行人
    // company_base_tag_search_fxxx_cpws	高级搜索-风险信息-裁判文书
    // company_base_tag_search_fxxx_ktgg	高级搜索-风险信息-开庭公告
    // company_base_tag_search_fxxx_fygg	高级搜索-风险信息-法院公告
    // company_base_tag_search_fxxx_xzcf	高级搜索-风险信息-行政处罚
    // company_base_tag_search_fxxx_dcdy	高级搜索-风险信息-动产抵押
    // company_base_tag_search_fxxx_jyyc	高级搜索-风险信息-经营异常
    // company_base_tag_search_fxxx_bzxr	高级搜索-风险信息-被执行人
    // company_base_tag_search_fxxx_xzgxf	高级搜索-风险信息-限制高消费
    // company_base_tag_search_jyxx_zllx	高级搜索-经营信息-专利类型
    // company_base_tag_search_jyxx_zzzs	高级搜索-经营信息-资质证书
    // company_base_tag_search_jyxx_kjxqy	高级搜索-经营信息-科技型企业
    // company_base_tag_search_jyxx_zscq	高级搜索-经营信息-知识产权
    // company_base_tag_search_jyxx_gdsx	高级搜索-经营信息-更多筛选
    // company_base_tag_search_rzss_rzxx	高级搜索-融资上市-融资信息
    async getList() {
      let tags = [
        "company_base_tag_search",
        "company_base_tag_search_gsxx_cbrs",
        "company_base_tag_search_gsxx_clnx",
        "company_base_tag_search_gsxx_qyzd",
        "company_base_tag_search_gsxx_zczb",
        "company_base_tag_search_gsxx_sjzb",
        "company_base_tag_search_gsxx_zblx",
        "company_base_tag_search_gsxx_qylx",
        "company_base_tag_search_gsxx_zjjg",
        "company_base_tag_search_lxfs_ysdjz",
        "company_base_tag_search_lxfs_lxdh",
        "company_base_tag_search_lxfs_sjhm",
        "company_base_tag_search_lxfs_gddh",
        "company_base_tag_search_lxfs_gwdh",
        "company_base_tag_search_lxfs_gzldh",
        "company_base_tag_search_lxfs_lxyx",
        "company_base_tag_search_fxxx_sxbzxr",
        "company_base_tag_search_fxxx_cpws",
        "company_base_tag_search_fxxx_ktgg",
        "company_base_tag_search_fxxx_fygg",
        "company_base_tag_search_fxxx_xzcf",
        "company_base_tag_search_fxxx_dcdy",
        "company_base_tag_search_fxxx_jyyc",
        "company_base_tag_search_fxxx_bzxr",
        "company_base_tag_search_fxxx_xzgxf",
        "company_base_tag_search_jyxx_zllx",
        "company_base_tag_search_jyxx_zzzs",
        "company_base_tag_search_jyxx_kjxqy",
        "company_base_tag_search_jyxx_zscq",
        "company_base_tag_search_jyxx_gdsx",
        "company_base_tag_search_rzss_rzxx",
      ];
	  let queryParams = {
	  	pageNumber: 1,
	  	pageSize: 1000,
	  	formData: true,
	  	searchParams: {},
	  	data: { configCode: tags.join(",") },
	  }
	  qylxdictapi(queryParams).then(res => {
		  let tagsList = res.data.content;
		  let treeList = this.toTree(tagsList);
		  console.log('treeList',treeList)
		  let tempTreeList = [];
		  //     v.name == "融资信息" || 已有
		  //     v.name == "地址信息" || 无
		  
		  //  v.name == "联系方式" 改
		  //  v.name == "风险信息" 改
		  
		  // treeList.forEach((v) => {
		  //   if (
		  //     v.name == "融资信息" ||
		  //     v.name == "联系方式" ||
		  //     v.name == "地址信息" ||
		  //     v.name == "风险信息"
		  //   ) {
		  //     tempTreeList = tempTreeList.concat(v);
		  //   } else {
		  //     if (v.children) {
		  //       v.children.forEach((k) => {
		  //         if (k.children) {
		  //           tempTreeList.push(k);
		  //         }
		  //       });
		  //     }
		  //   }
		  // });
		  let lxName = {
		    id: "costomLxId",
		    name: "联系方式",
		    list: {
		      疑似代记账: "company_base_tag_search_lxfs_ysdjz",
		      联系电话: "company_base_tag_search_lxfs_lxdh",
		      手机号码: "company_base_tag_search_lxfs_sjhm",
		      固定电话: "company_base_tag_search_lxfs_gddh",
		      官网电话: "company_base_tag_search_lxfs_gwdh",
		      高质量电话: "company_base_tag_search_lxfs_gzldh",
		      联系邮箱: "company_base_tag_search_lxfs_lxyx",
		    },
		  };
		  let fxName = {
		    id: "costomFxId",
		    name: "风险信息",
		    list: {
		      失信被执行人: "company_base_tag_search_fxxx_sxbzxr",
		      裁判文书: "company_base_tag_search_fxxx_cpws",
		      开庭公告: "company_base_tag_search_fxxx_ktgg",
		      法院公告: "company_base_tag_search_fxxx_fygg",
		      行政处罚: "company_base_tag_search_fxxx_xzcf",
		      动产抵押: "company_base_tag_search_fxxx_dcdy",
		      经营异常: "company_base_tag_search_fxxx_jyyc",
		      被执行人: "company_base_tag_search_fxxx_bzxr",
		      限制高消费: "company_base_tag_search_fxxx_xzgxf",
		    },
		  };
		  let gsName = {
		    name: "工商信息",
		    list: {
		      参保人数: "company_base_tag_search_gsxx_cbrs",
		      成立年限: "company_base_tag_search_gsxx_clnx",
		      企业状态: "company_base_tag_search_gsxx_qyzd",
		      注册资金: "company_base_tag_search_gsxx_zczb",
		      实缴资本: "company_base_tag_search_gsxx_sjzb",
		      资本类型: "company_base_tag_search_gsxx_zblx",
		      企业类型: "company_base_tag_search_gsxx_qylx",
		      组织机构: "company_base_tag_search_gsxx_zjjg",
		    },
		  };
		  let jyName = {
		    name: "经营信息",
		    list: {
		      专利类型: "company_base_tag_search_jyxx_zllx",
		      资质证书: "company_base_tag_search_jyxx_zzzs",
		      科技型企业: "company_base_tag_search_jyxx_kjxqy",
		      知识产权: "company_base_tag_search_jyxx_zscq",
		      更多筛选: "company_base_tag_search_jyxx_gdsx",
		    },
		  };
		  let rzName = {
		    name: "融资信息",
		    list: {
		      融资信息: "company_base_tag_search_rzss_rzxx",
		    },
		  };
		  treeList.forEach((v) => {
		    [lxName, fxName, gsName, jyName, rzName].forEach((j) => {
		      if (Object.keys(j.list).indexOf(v.name) != -1) {
		        this.deep(v.children, j.list[v.name]);
		      }
		    });
		  });
		  treeList.forEach((v) => {
		    if (
		      Object.keys(fxName.list).indexOf(v.name) == -1 &&
		      Object.keys(lxName.list).indexOf(v.name) == -1
		    ) {
		      tempTreeList.push(v);
			  
		    } else {
		      this.pushCostomData(v, fxName, tempTreeList);
		      this.pushCostomData(v, lxName, tempTreeList);
		    }
			
		  });
		  console.log('tempTreeList',tempTreeList)
		  tempTreeList.unshift({
		    name: "行业分类",
		    type: "customPicker",
		    _id: "customPicker_cate",
		    children: [
		      {
		        name: "全部行业",
		      },
		    ],
		  });
		  tempTreeList.unshift({
		    name: "搜索范围",
		    type: "customSearch",
		    _id: "customSearch_fw",
		    children: this.fwList,
		  });
		  tempTreeList.unshift({
		    name: "关键词",
		    type: "input",
		    placeHolder: "输入关键词",
		    _id: "input_kw",
		  });
		  tempTreeList.forEach((v) => {
		    //获取最深层级
		    v.deepNum = this.getDepth(v);
		    if (v.deepNum > 2) {
		      v.children.forEach((k) => {
		        k.deepNum = this.getDepth(k);
		        if (k.children && k.children.length) {
		          k.children.unshift({
		            name: "不限",
		            _id: "",
		          });
		          if (k.deepNum == 3) {
		            k.children.forEach((j) => {
		              j.children = [
		                {
		                  name: "不限",
		                  _id: "",
		                },
		              ].concat(j.children || []);
		            });
		          }
		        }
		      });
		    }
		  });
		  let moreList = tempTreeList.filter((v) => v.name == "更多筛选");
		  // 隐藏组织机构
		  this.treeList = tempTreeList
		    .map((v) => {
		      if (v.name == "参保人数") {
		        (v.type = "customParam"), (v.param = "cbrs");
		      } else if (v.name == "成立年限") {
		        (v.type = "customParam"), (v.param = "clnx");
		      } else if (v.name == "注册资金" || v.name == "注册资本") {
		        (v.type = "customParam"), (v.param = "zczb");
		      } else if (v.name == "实缴资本") {
		        (v.type = "customParam"), (v.param = "sjzb");
		      }
		      return {
		        ...v,
		      };
		    })
		    .filter((v) => v.name != "组织机构" && v.name != "更多筛选")
		    .concat(moreList);
		  this.selectFormatList();
	  })
      
    },
  },
  created() {
    this.pickerList = Object.assign({}, this.savePickerList);
    this.getList();
    this.$forceUpdate();
    this.$nextTick(() => {
      document.getElementById("listContent").addEventListener("scroll", (e) => {
        let tag = document.querySelectorAll(".filter-box");
        let index = 0;
        for (let i = 0; i < tag.length; i++) {
          if (
            Math.abs(tag[i].getBoundingClientRect().top) <
            Math.abs(tag[index].getBoundingClientRect().top)
          ) {
            index = i;
          }
        }
        let id = tag[index].getAttribute("id");
        if (id) {
          this.activeItemIndex = this.treeList.findIndex((v) => v._id == id);
        }
        if (
          e.target.scrollTop + e.target.clientHeight >=
          e.target.scrollHeight
        ) {
          this.activeItemIndex = this.treeList.length - 1;
        }
      });
    });
  },
  beforeRouteLeave(to, from, next) {
    if (to.name == "home-enterprise") {
      to.meta.keepAlive = false;
    }
    next();
  },
};
</script>

<style lang="scss" scoped>
.filter-box {
  &.is-hidden {
    display: none;
  }

  .filter-title {
    padding: 8px 12px;
    font-family: PingFang SC, PingFang SC;
    font-weight: bold;
    font-size: 15px;
    color: #222222;
    line-height: 18px;
    text-align: left;
    font-style: normal;
    text-transform: none;
    margin-bottom: 4px;
  }

  .filter-tags {
    padding: 0 12px;
    display: flex;
    flex-flow: row wrap;
    justify-content: flex-start;
    align-items: center;
  }

  .filter-tags.is-column {
    flex-flow: column nowrap;
    justify-content: flex-start;
    align-items: flex-start;
  }
}

.filter-tag {
  // background: #f5f7fa;
  background: url(../../assets/images/checkbox-input.png) no-repeat 12px center;
  border-radius: 6px 6px 6px 6px;
  padding: 6px 14px 6px 32px;
  font-family: PingFang SC, PingFang SC;
  font-weight: 400;
  font-size: 14px;
  color: #222222;
  line-height: 16px;
  text-align: left;
  font-style: normal;
  text-transform: none;
  margin-right: 8px;
  margin-bottom: 10px;
  position: relative;
  cursor: pointer;

  &.is-selected {
    background: url(../../assets/images/hcheckbox-input.png) no-repeat 12px center;
    color: #227FE4;
  }
  &.is-selected::after {
    // background: url("./images/icon-filter-more-w.png") no-repeat center/cover !important;
  }
}

.filter-tags.is-column .filter-tag {
  width: auto;
  height: 36px;
  line-height: 36px;
  padding: 0 14px;
  margin-right: auto;
  box-sizing: border-box;
  display: inline-block;

  &::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 50%;
    width: 14px;
    height: 14px;
    transform: translate(0, -50%);
    // background: url("./images/icon-filter-more.png") no-repeat center/cover;
  }
}

.main-box {
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  // width: 100%;
  // height: calc(100vh - 64px);
}

.sidebar {
  flex-shrink: 0;
  width: 96px;
  height: 100%;
  background: #f8f9fa;
  overflow: hidden auto;
}

.content {
  flex: auto;
  height: 100%;
  background: #fff;
  overflow: hidden auto;
}

.filter-footer {
  background: #FFFFFF;
  box-shadow: 0px -2px 12px 0px rgba(7,28,69,0.25);
  border-radius: 0px 0px 0px 0px;
  border-top: 1px solid #E0E0E0;
  padding: 21px 0;
  overflow: hidden;
  line-height: 36px;
  font-size: 14px;
  color: #222222;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index:9999;
  .number{
  	color:#FF596A
  }

  .footer-button {
    height: 44px;
    border-radius: 6px 6px 6px 6px;
    border: 1px solid #3360d7;
    font-family: PingFang SC, PingFang SC;
    font-weight: 500;
    font-size: 15px;
    color: #3360d7;
    text-align: center;
    font-style: normal;
    text-transform: none;
    background-color: #fff;
    .van-loading {
      width: 20px;
      height: 20px;
      margin-right: 15px;
    }
  }

  .footer-button:first-of-type {
    flex-shrink: 0;
    width: 88px;
    margin-right: 9px;
  }

  .footer-button.is-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    background: #3360d7;
    color: #fff;
  }
}
.search-block {
  display: flex;
  align-items: center;
  .search-inp {
    display: flex;
    align-items: center;
    width: 195px;
    height: 36px;
    background: #f3f5f8;
    border-radius: 4px;
    margin-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
    .search-icon {
      width: 16px;
      height: 16px;
      margin-left: 16px;
      margin-right: 6px;
    }
    .inp {
      width: 125px;
      background: #f3f5f8;
    }
  }
  .search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 36px;
    background: #3460d7;
    font-family: PingFang SC, PingFang SC;
    font-weight: 400;
    font-size: 14px;
    color: #ffffff;
    line-height: 16px;
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
  }
}
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none; //此处就是去掉默认的小×
}
</style>
